#ifndef FPS_H
#define FPS_H

#include <chrono>

#include "config.h"

namespace Fps {     // 该名字空间负责计算fps

    using namespace std::chrono;

    class Fps {     // Fps类提供fps计算的接口
    public:
        explicit Fps(int fps_itv =frame_interval) : start{high_resolution_clock::now()}, interval{fps_itv}, frames{}, present_fps{static_cast<double>(frame_update)} { }
        double get_fps() const { return present_fps; }
        void update_fps();      // 更新fps
    private:
        decltype(high_resolution_clock::now()) start;
        int interval;
        int frames;
        double present_fps;
    };

}

#endif // FPS_H
